\(\int \frac {(a+b \tan (e+f x))^m (A+B \tan (e+f x)+C \tan ^2(e+f x))}{(c+d \tan (e+f x))^3} \, dx\) [171]

   Optimal result
   Rubi [A] (verified)
   Mathematica [B] (verified)
   Maple [F]
   Fricas [F]
   Sympy [F]
   Maxima [F(-1)]
   Giac [F]
   Mupad [F(-1)]

Optimal result

Integrand size = 45, antiderivative size = 702 \[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\frac {(A-i B-C) \operatorname {Hypergeometric2F1}\left (1,1+m,2+m,\frac {a+b \tan (e+f x)}{a-i b}\right ) (a+b \tan (e+f x))^{1+m}}{2 (i a+b) (c-i d)^3 f (1+m)}+\frac {(A+i B-C) \operatorname {Hypergeometric2F1}\left (1,1+m,2+m,\frac {a+b \tan (e+f x)}{a+i b}\right ) (a+b \tan (e+f x))^{1+m}}{2 (a+i b) (i c-d)^3 f (1+m)}+\frac {\left (2 a^2 d^3 \left ((A-C) d \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right )-2 a b d^2 \left (B \left (6 c^2 d^2-c^4 (2-m)-d^4 m\right )+2 c (A-C) d \left (c^2 (3-m)-d^2 (1+m)\right )\right )-b^2 \left (A d^2 \left (d^4 (1-m) m+2 c^2 d^2 \left (1+3 m-m^2\right )-c^4 \left (6-5 m+m^2\right )\right )+B c d \left (d^4 m (1+m)-2 c^2 d^2 \left (3+m-m^2\right )+c^4 \left (2-3 m+m^2\right )\right )+c^2 C \left (c^4 (1-m) m+2 c^2 d^2 \left (3-m-m^2\right )-d^4 \left (2+3 m+m^2\right )\right )\right )\right ) \operatorname {Hypergeometric2F1}\left (1,1+m,2+m,-\frac {d (a+b \tan (e+f x))}{b c-a d}\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^3 \left (c^2+d^2\right )^3 f (1+m)}+\frac {\left (c^2 C-B c d+A d^2\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d) \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}-\frac {\left (2 a d^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right )-b \left (c^4 C (1-m)+A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (1+m)+c^2 d^2 (A (5-m)-C (3+m))\right )\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^2 \left (c^2+d^2\right )^2 f (c+d \tan (e+f x))} \]

[Out]

1/2*(A-I*B-C)*hypergeom([1, 1+m],[2+m],(a+b*tan(f*x+e))/(a-I*b))*(a+b*tan(f*x+e))^(1+m)/(I*a+b)/(c-I*d)^3/f/(1
+m)+1/2*(A+I*B-C)*hypergeom([1, 1+m],[2+m],(a+b*tan(f*x+e))/(a+I*b))*(a+b*tan(f*x+e))^(1+m)/(a+I*b)/(I*c-d)^3/
f/(1+m)+1/2*(2*a^2*d^3*((A-C)*d*(3*c^2-d^2)-B*(c^3-3*c*d^2))-2*a*b*d^2*(B*(6*c^2*d^2-c^4*(2-m)-d^4*m)+2*c*(A-C
)*d*(c^2*(3-m)-d^2*(1+m)))-b^2*(A*d^2*(d^4*(1-m)*m+2*c^2*d^2*(-m^2+3*m+1)-c^4*(m^2-5*m+6))+B*c*d*(d^4*m*(1+m)-
2*c^2*d^2*(-m^2+m+3)+c^4*(m^2-3*m+2))+c^2*C*(c^4*(1-m)*m+2*c^2*d^2*(-m^2-m+3)-d^4*(m^2+3*m+2))))*hypergeom([1,
 1+m],[2+m],-d*(a+b*tan(f*x+e))/(-a*d+b*c))*(a+b*tan(f*x+e))^(1+m)/(-a*d+b*c)^3/(c^2+d^2)^3/f/(1+m)+1/2*(A*d^2
-B*c*d+C*c^2)*(a+b*tan(f*x+e))^(1+m)/(-a*d+b*c)/(c^2+d^2)/f/(c+d*tan(f*x+e))^2-1/2*(2*a*d^2*(2*c*(A-C)*d-B*(c^
2-d^2))-b*(c^4*C*(1-m)+A*d^4*(1-m)-B*c^3*d*(3-m)+B*c*d^3*(1+m)+c^2*d^2*(A*(5-m)-C*(3+m))))*(a+b*tan(f*x+e))^(1
+m)/(-a*d+b*c)^2/(c^2+d^2)^2/f/(c+d*tan(f*x+e))

Rubi [A] (verified)

Time = 3.24 (sec) , antiderivative size = 702, normalized size of antiderivative = 1.00, number of steps used = 10, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.133, Rules used = {3730, 3734, 3620, 3618, 70, 3715} \[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\frac {(a+b \tan (e+f x))^{m+1} \left (2 a^2 d^3 \left (d (A-C) \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right )-2 a b d^2 \left (2 c d (A-C) \left (c^2 (3-m)-d^2 (m+1)\right )+B \left (-\left (c^4 (2-m)\right )+6 c^2 d^2-d^4 m\right )\right )-b^2 \left (A d^2 \left (-\left (c^4 \left (m^2-5 m+6\right )\right )+2 c^2 d^2 \left (-m^2+3 m+1\right )+d^4 (1-m) m\right )+B \left (c^5 d \left (m^2-3 m+2\right )-2 c^3 d^3 \left (-m^2+m+3\right )+c d^5 m (m+1)\right )+c^2 C \left (c^4 (1-m) m+2 c^2 d^2 \left (-m^2-m+3\right )-d^4 \left (m^2+3 m+2\right )\right )\right )\right ) \operatorname {Hypergeometric2F1}\left (1,m+1,m+2,-\frac {d (a+b \tan (e+f x))}{b c-a d}\right )}{2 f (m+1) \left (c^2+d^2\right )^3 (b c-a d)^3}+\frac {\left (A d^2-B c d+c^2 C\right ) (a+b \tan (e+f x))^{m+1}}{2 f \left (c^2+d^2\right ) (b c-a d) (c+d \tan (e+f x))^2}-\frac {(a+b \tan (e+f x))^{m+1} \left (2 a d^2 \left (2 c d (A-C)-B \left (c^2-d^2\right )\right )-b \left (c^2 d^2 (A (5-m)-C (m+3))+A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (m+1)+c^4 C (1-m)\right )\right )}{2 f \left (c^2+d^2\right )^2 (b c-a d)^2 (c+d \tan (e+f x))}+\frac {(A-i B-C) (a+b \tan (e+f x))^{m+1} \operatorname {Hypergeometric2F1}\left (1,m+1,m+2,\frac {a+b \tan (e+f x)}{a-i b}\right )}{2 f (m+1) (b+i a) (c-i d)^3}+\frac {(A+i B-C) (a+b \tan (e+f x))^{m+1} \operatorname {Hypergeometric2F1}\left (1,m+1,m+2,\frac {a+b \tan (e+f x)}{a+i b}\right )}{2 f (m+1) (a+i b) (-d+i c)^3} \]

[In]

Int[((a + b*Tan[e + f*x])^m*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2))/(c + d*Tan[e + f*x])^3,x]

[Out]

((A - I*B - C)*Hypergeometric2F1[1, 1 + m, 2 + m, (a + b*Tan[e + f*x])/(a - I*b)]*(a + b*Tan[e + f*x])^(1 + m)
)/(2*(I*a + b)*(c - I*d)^3*f*(1 + m)) + ((A + I*B - C)*Hypergeometric2F1[1, 1 + m, 2 + m, (a + b*Tan[e + f*x])
/(a + I*b)]*(a + b*Tan[e + f*x])^(1 + m))/(2*(a + I*b)*(I*c - d)^3*f*(1 + m)) + ((2*a^2*d^3*((A - C)*d*(3*c^2
- d^2) - B*(c^3 - 3*c*d^2)) - 2*a*b*d^2*(B*(6*c^2*d^2 - c^4*(2 - m) - d^4*m) + 2*c*(A - C)*d*(c^2*(3 - m) - d^
2*(1 + m))) - b^2*(A*d^2*(d^4*(1 - m)*m + 2*c^2*d^2*(1 + 3*m - m^2) - c^4*(6 - 5*m + m^2)) + B*(c*d^5*m*(1 + m
) - 2*c^3*d^3*(3 + m - m^2) + c^5*d*(2 - 3*m + m^2)) + c^2*C*(c^4*(1 - m)*m + 2*c^2*d^2*(3 - m - m^2) - d^4*(2
 + 3*m + m^2))))*Hypergeometric2F1[1, 1 + m, 2 + m, -((d*(a + b*Tan[e + f*x]))/(b*c - a*d))]*(a + b*Tan[e + f*
x])^(1 + m))/(2*(b*c - a*d)^3*(c^2 + d^2)^3*f*(1 + m)) + ((c^2*C - B*c*d + A*d^2)*(a + b*Tan[e + f*x])^(1 + m)
)/(2*(b*c - a*d)*(c^2 + d^2)*f*(c + d*Tan[e + f*x])^2) - ((2*a*d^2*(2*c*(A - C)*d - B*(c^2 - d^2)) - b*(c^4*C*
(1 - m) + A*d^4*(1 - m) - B*c^3*d*(3 - m) + B*c*d^3*(1 + m) + c^2*d^2*(A*(5 - m) - C*(3 + m))))*(a + b*Tan[e +
 f*x])^(1 + m))/(2*(b*c - a*d)^2*(c^2 + d^2)^2*f*(c + d*Tan[e + f*x]))

Rule 70

Int[((a_) + (b_.)*(x_))^(m_)*((c_) + (d_.)*(x_))^(n_), x_Symbol] :> Simp[(b*c - a*d)^n*((a + b*x)^(m + 1)/(b^(
n + 1)*(m + 1)))*Hypergeometric2F1[-n, m + 1, m + 2, (-d)*((a + b*x)/(b*c - a*d))], x] /; FreeQ[{a, b, c, d, m
}, x] && NeQ[b*c - a*d, 0] &&  !IntegerQ[m] && IntegerQ[n]

Rule 3618

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Dist[c*(
d/f), Subst[Int[(a + (b/d)*x)^m/(d^2 + c*x), x], x, d*Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, m}, x] &&
NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && EqQ[c^2 + d^2, 0]

Rule 3620

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Dist[(c
 + I*d)/2, Int[(a + b*Tan[e + f*x])^m*(1 - I*Tan[e + f*x]), x], x] + Dist[(c - I*d)/2, Int[(a + b*Tan[e + f*x]
)^m*(1 + I*Tan[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f, m}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0]
&& NeQ[c^2 + d^2, 0] &&  !IntegerQ[m]

Rule 3715

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_.)*((A_) + (C_.)*
tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Dist[A/f, Subst[Int[(a + b*x)^m*(c + d*x)^n, x], x, Tan[e + f*x]], x]
 /; FreeQ[{a, b, c, d, e, f, A, C, m, n}, x] && EqQ[A, C]

Rule 3730

Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_)*((A_.) + (B_.)*t
an[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (f_.)*(x_)]^2), x_Symbol] :> Simp[(A*b^2 - a*(b*B - a*C))*(a + b*Ta
n[e + f*x])^(m + 1)*((c + d*Tan[e + f*x])^(n + 1)/(f*(m + 1)*(b*c - a*d)*(a^2 + b^2))), x] + Dist[1/((m + 1)*(
b*c - a*d)*(a^2 + b^2)), Int[(a + b*Tan[e + f*x])^(m + 1)*(c + d*Tan[e + f*x])^n*Simp[A*(a*(b*c - a*d)*(m + 1)
 - b^2*d*(m + n + 2)) + (b*B - a*C)*(b*c*(m + 1) + a*d*(n + 1)) - (m + 1)*(b*c - a*d)*(A*b - a*B - b*C)*Tan[e
+ f*x] - d*(A*b^2 - a*(b*B - a*C))*(m + n + 2)*Tan[e + f*x]^2, x], x], x] /; FreeQ[{a, b, c, d, e, f, A, B, C,
 n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] && LtQ[m, -1] &&  !(ILtQ[n, -1] && ( !I
ntegerQ[m] || (EqQ[c, 0] && NeQ[a, 0])))

Rule 3734

Int[(((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])^(n_)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)] + (C_.)*tan[(e_.) + (
f_.)*(x_)]^2))/((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)]), x_Symbol] :> Dist[1/(a^2 + b^2), Int[(c + d*Tan[e + f*
x])^n*Simp[b*B + a*(A - C) + (a*B - b*(A - C))*Tan[e + f*x], x], x], x] + Dist[(A*b^2 - a*b*B + a^2*C)/(a^2 +
b^2), Int[(c + d*Tan[e + f*x])^n*((1 + Tan[e + f*x]^2)/(a + b*Tan[e + f*x])), x], x] /; FreeQ[{a, b, c, d, e,
f, A, B, C, n}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && NeQ[c^2 + d^2, 0] &&  !GtQ[n, 0] &&  !LeQ[n, -
1]

Rubi steps \begin{align*} \text {integral}& = \frac {\left (c^2 C-B c d+A d^2\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d) \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}+\frac {\int \frac {(a+b \tan (e+f x))^m \left (A \left (2 c (b c-a d)+b d^2 (1-m)\right )+(c C-B d) (2 a d-b c (1+m))+2 (b c-a d) (B c-(A-C) d) \tan (e+f x)+b \left (c^2 C-B c d+A d^2\right ) (1-m) \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^2} \, dx}{2 (b c-a d) \left (c^2+d^2\right )} \\ & = \frac {\left (c^2 C-B c d+A d^2\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d) \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}-\frac {\left (2 a d^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right )-b \left (c^4 C (1-m)+A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (1+m)+c^2 d^2 (A (5-m)-C (3+m))\right )\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^2 \left (c^2+d^2\right )^2 f (c+d \tan (e+f x))}+\frac {\int \frac {(a+b \tan (e+f x))^m \left (-\left (\left (2 d (b c-a d) (B c-(A-C) d)-b c \left (c^2 C-B c d+A d^2\right ) (1-m)\right ) (a d-b c (1+m))\right )-\left (a c d-b \left (c^2-d^2 m\right )\right ) \left (A \left (2 c (b c-a d)+b d^2 (1-m)\right )+(c C-B d) (2 a d-b c (1+m))\right )-2 (b c-a d)^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right ) \tan (e+f x)+b m \left (2 a d^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right )-b \left (A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (1+m)+c^4 (C-C m)+c^2 d^2 (A (5-m)-C (3+m))\right )\right ) \tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx}{2 (b c-a d)^2 \left (c^2+d^2\right )^2} \\ & = \frac {\left (c^2 C-B c d+A d^2\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d) \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}-\frac {\left (2 a d^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right )-b \left (c^4 C (1-m)+A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (1+m)+c^2 d^2 (A (5-m)-C (3+m))\right )\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^2 \left (c^2+d^2\right )^2 f (c+d \tan (e+f x))}+\frac {\int (a+b \tan (e+f x))^m \left (2 (b c-a d)^2 \left (A c^3-c^3 C+3 B c^2 d-3 A c d^2+3 c C d^2-B d^3\right )-2 (b c-a d)^2 \left ((A-C) d \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right ) \tan (e+f x)\right ) \, dx}{2 (b c-a d)^2 \left (c^2+d^2\right )^3}+\frac {\left (2 a^2 d^3 \left ((A-C) d \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right )-2 a b d^2 \left (B \left (6 c^2 d^2-c^4 (2-m)-d^4 m\right )+2 c (A-C) d \left (c^2 (3-m)-d^2 (1+m)\right )\right )-b^2 \left (A d^2 \left (d^4 (1-m) m+2 c^2 d^2 \left (1+3 m-m^2\right )-c^4 \left (6-5 m+m^2\right )\right )+B \left (c d^5 m (1+m)-2 c^3 d^3 \left (3+m-m^2\right )+c^5 d \left (2-3 m+m^2\right )\right )+c^2 C \left (c^4 (1-m) m+2 c^2 d^2 \left (3-m-m^2\right )-d^4 \left (2+3 m+m^2\right )\right )\right )\right ) \int \frac {(a+b \tan (e+f x))^m \left (1+\tan ^2(e+f x)\right )}{c+d \tan (e+f x)} \, dx}{2 (b c-a d)^2 \left (c^2+d^2\right )^3} \\ & = \frac {\left (c^2 C-B c d+A d^2\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d) \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}-\frac {\left (2 a d^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right )-b \left (c^4 C (1-m)+A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (1+m)+c^2 d^2 (A (5-m)-C (3+m))\right )\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^2 \left (c^2+d^2\right )^2 f (c+d \tan (e+f x))}+\frac {(A-i B-C) \int (1+i \tan (e+f x)) (a+b \tan (e+f x))^m \, dx}{2 (c-i d)^3}+\frac {(A+i B-C) \int (1-i \tan (e+f x)) (a+b \tan (e+f x))^m \, dx}{2 (c+i d)^3}+\frac {\left (2 a^2 d^3 \left ((A-C) d \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right )-2 a b d^2 \left (B \left (6 c^2 d^2-c^4 (2-m)-d^4 m\right )+2 c (A-C) d \left (c^2 (3-m)-d^2 (1+m)\right )\right )-b^2 \left (A d^2 \left (d^4 (1-m) m+2 c^2 d^2 \left (1+3 m-m^2\right )-c^4 \left (6-5 m+m^2\right )\right )+B \left (c d^5 m (1+m)-2 c^3 d^3 \left (3+m-m^2\right )+c^5 d \left (2-3 m+m^2\right )\right )+c^2 C \left (c^4 (1-m) m+2 c^2 d^2 \left (3-m-m^2\right )-d^4 \left (2+3 m+m^2\right )\right )\right )\right ) \text {Subst}\left (\int \frac {(a+b x)^m}{c+d x} \, dx,x,\tan (e+f x)\right )}{2 (b c-a d)^2 \left (c^2+d^2\right )^3 f} \\ & = \frac {\left (2 a^2 d^3 \left ((A-C) d \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right )-2 a b d^2 \left (B \left (6 c^2 d^2-c^4 (2-m)-d^4 m\right )+2 c (A-C) d \left (c^2 (3-m)-d^2 (1+m)\right )\right )-b^2 \left (A d^2 \left (d^4 (1-m) m+2 c^2 d^2 \left (1+3 m-m^2\right )-c^4 \left (6-5 m+m^2\right )\right )+B \left (c d^5 m (1+m)-2 c^3 d^3 \left (3+m-m^2\right )+c^5 d \left (2-3 m+m^2\right )\right )+c^2 C \left (c^4 (1-m) m+2 c^2 d^2 \left (3-m-m^2\right )-d^4 \left (2+3 m+m^2\right )\right )\right )\right ) \operatorname {Hypergeometric2F1}\left (1,1+m,2+m,-\frac {d (a+b \tan (e+f x))}{b c-a d}\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^3 \left (c^2+d^2\right )^3 f (1+m)}+\frac {\left (c^2 C-B c d+A d^2\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d) \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}-\frac {\left (2 a d^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right )-b \left (c^4 C (1-m)+A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (1+m)+c^2 d^2 (A (5-m)-C (3+m))\right )\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^2 \left (c^2+d^2\right )^2 f (c+d \tan (e+f x))}-\frac {(i (A+i B-C)) \text {Subst}\left (\int \frac {(a+i b x)^m}{-1+x} \, dx,x,-i \tan (e+f x)\right )}{2 (c+i d)^3 f}+\frac {(A-i B-C) \text {Subst}\left (\int \frac {(a-i b x)^m}{-1+x} \, dx,x,i \tan (e+f x)\right )}{2 (i c+d)^3 f} \\ & = -\frac {(A-i B-C) \operatorname {Hypergeometric2F1}\left (1,1+m,2+m,\frac {a+b \tan (e+f x)}{a-i b}\right ) (a+b \tan (e+f x))^{1+m}}{2 (a-i b) (i c+d)^3 f (1+m)}-\frac {(A+i B-C) \operatorname {Hypergeometric2F1}\left (1,1+m,2+m,\frac {a+b \tan (e+f x)}{a+i b}\right ) (a+b \tan (e+f x))^{1+m}}{2 (i a-b) (c+i d)^3 f (1+m)}+\frac {\left (2 a^2 d^3 \left ((A-C) d \left (3 c^2-d^2\right )-B \left (c^3-3 c d^2\right )\right )-2 a b d^2 \left (B \left (6 c^2 d^2-c^4 (2-m)-d^4 m\right )+2 c (A-C) d \left (c^2 (3-m)-d^2 (1+m)\right )\right )-b^2 \left (A d^2 \left (d^4 (1-m) m+2 c^2 d^2 \left (1+3 m-m^2\right )-c^4 \left (6-5 m+m^2\right )\right )+B \left (c d^5 m (1+m)-2 c^3 d^3 \left (3+m-m^2\right )+c^5 d \left (2-3 m+m^2\right )\right )+c^2 C \left (c^4 (1-m) m+2 c^2 d^2 \left (3-m-m^2\right )-d^4 \left (2+3 m+m^2\right )\right )\right )\right ) \operatorname {Hypergeometric2F1}\left (1,1+m,2+m,-\frac {d (a+b \tan (e+f x))}{b c-a d}\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^3 \left (c^2+d^2\right )^3 f (1+m)}+\frac {\left (c^2 C-B c d+A d^2\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d) \left (c^2+d^2\right ) f (c+d \tan (e+f x))^2}-\frac {\left (2 a d^2 \left (2 c (A-C) d-B \left (c^2-d^2\right )\right )-b \left (c^4 C (1-m)+A d^4 (1-m)-B c^3 d (3-m)+B c d^3 (1+m)+c^2 d^2 (A (5-m)-C (3+m))\right )\right ) (a+b \tan (e+f x))^{1+m}}{2 (b c-a d)^2 \left (c^2+d^2\right )^2 f (c+d \tan (e+f x))} \\ \end{align*}

Mathematica [B] (verified)

Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(2238\) vs. \(2(702)=1404\).

Time = 6.33 (sec) , antiderivative size = 2238, normalized size of antiderivative = 3.19 \[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\text {Result too large to show} \]

[In]

Integrate[((a + b*Tan[e + f*x])^m*(A + B*Tan[e + f*x] + C*Tan[e + f*x]^2))/(c + d*Tan[e + f*x])^3,x]

[Out]

-1/2*((A*d^2 - c*(-(c*C) + B*d))*(a + b*Tan[e + f*x])^(1 + m))/((-(b*c) + a*d)*(c^2 + d^2)*f*(c + d*Tan[e + f*
x])^2) - (-(((-(c*(2*d*(b*c - a*d)*(B*c - (A - C)*d) - b*c*(c^2*C - B*c*d + A*d^2)*(1 - m))) + d^2*(A*(2*c*(b*
c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m))))*(a + b*Tan[e + f*x])^(1 + m))/((-(b*c) + a*d)*
(c^2 + d^2)*f*(c + d*Tan[e + f*x]))) - (-(((-(c*d*(-(b*c) + a*d)*(-2*c*(b*c - a*d)*(B*c - (A - C)*d) - b*d*(c^
2*C - B*c*d + A*d^2)*(1 - m) + d*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m))))) -
 b*c^2*m*(-(c*(2*d*(b*c - a*d)*(B*c - (A - C)*d) - b*c*(c^2*C - B*c*d + A*d^2)*(1 - m))) + d^2*(A*(2*c*(b*c -
a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m)))) + d^2*((2*d*(b*c - a*d)*(B*c - (A - C)*d) - b*c*(c
^2*C - B*c*d + A*d^2)*(1 - m))*(-(a*d) + b*c*(1 + m)) + (-(c*(-(b*c) + a*d)) - b*d^2*m)*(A*(2*c*(b*c - a*d) +
b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m)))))*Hypergeometric2F1[1, 1 + m, 2 + m, (d*(a + b*Tan[e + f*x
]))/(-(b*c) + a*d)]*(a + b*Tan[e + f*x])^(1 + m))/((-(b*c) + a*d)*(c^2 + d^2)*f*(1 + m))) + (((I/2)*(d*(-(b*c)
 + a*d)*(-2*c*(b*c - a*d)*(B*c - (A - C)*d) - b*d*(c^2*C - B*c*d + A*d^2)*(1 - m) + d*(A*(2*c*(b*c - a*d) + b*
d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m)))) + c*((2*d*(b*c - a*d)*(B*c - (A - C)*d) - b*c*(c^2*C - B*c*
d + A*d^2)*(1 - m))*(-(a*d) + b*c*(1 + m)) + (-(c*(-(b*c) + a*d)) - b*d^2*m)*(A*(2*c*(b*c - a*d) + b*d^2*(1 -
m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m))) + b*m*(-(c*(2*d*(b*c - a*d)*(B*c - (A - C)*d) - b*c*(c^2*C - B*c*d +
A*d^2)*(1 - m))) + d^2*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m))))) + I*(c*(-(b
*c) + a*d)*(-2*c*(b*c - a*d)*(B*c - (A - C)*d) - b*d*(c^2*C - B*c*d + A*d^2)*(1 - m) + d*(A*(2*c*(b*c - a*d) +
 b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m)))) - d*((2*d*(b*c - a*d)*(B*c - (A - C)*d) - b*c*(c^2*C - B
*c*d + A*d^2)*(1 - m))*(-(a*d) + b*c*(1 + m)) + (-(c*(-(b*c) + a*d)) - b*d^2*m)*(A*(2*c*(b*c - a*d) + b*d^2*(1
 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m))) + b*m*(-(c*(2*d*(b*c - a*d)*(B*c - (A - C)*d) - b*c*(c^2*C - B*c*d
 + A*d^2)*(1 - m))) + d^2*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m)))))))*Hyperg
eometric2F1[1, 1 + m, 2 + m, ((-I)*a - I*b*Tan[e + f*x])/((-I)*a + b)]*(a + b*Tan[e + f*x])^(1 + m))/((a + I*b
)*f*(1 + m)) - ((I/2)*(d*(-(b*c) + a*d)*(-2*c*(b*c - a*d)*(B*c - (A - C)*d) - b*d*(c^2*C - B*c*d + A*d^2)*(1 -
 m) + d*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m)))) + c*((2*d*(b*c - a*d)*(B*c
- (A - C)*d) - b*c*(c^2*C - B*c*d + A*d^2)*(1 - m))*(-(a*d) + b*c*(1 + m)) + (-(c*(-(b*c) + a*d)) - b*d^2*m)*(
A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m))) + b*m*(-(c*(2*d*(b*c - a*d)*(B*c - (A
 - C)*d) - b*c*(c^2*C - B*c*d + A*d^2)*(1 - m))) + d^2*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a
*d - b*c*(1 + m))))) - I*(c*(-(b*c) + a*d)*(-2*c*(b*c - a*d)*(B*c - (A - C)*d) - b*d*(c^2*C - B*c*d + A*d^2)*(
1 - m) + d*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m)))) - d*((2*d*(b*c - a*d)*(B
*c - (A - C)*d) - b*c*(c^2*C - B*c*d + A*d^2)*(1 - m))*(-(a*d) + b*c*(1 + m)) + (-(c*(-(b*c) + a*d)) - b*d^2*m
)*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(2*a*d - b*c*(1 + m))) + b*m*(-(c*(2*d*(b*c - a*d)*(B*c -
 (A - C)*d) - b*c*(c^2*C - B*c*d + A*d^2)*(1 - m))) + d^2*(A*(2*c*(b*c - a*d) + b*d^2*(1 - m)) + (c*C - B*d)*(
2*a*d - b*c*(1 + m)))))))*Hypergeometric2F1[1, 1 + m, 2 + m, -((I*a + I*b*Tan[e + f*x])/((-I)*a - b))]*(a + b*
Tan[e + f*x])^(1 + m))/((a - I*b)*f*(1 + m)))/(c^2 + d^2))/((-(b*c) + a*d)*(c^2 + d^2)))/(2*(-(b*c) + a*d)*(c^
2 + d^2))

Maple [F]

\[\int \frac {\left (a +b \tan \left (f x +e \right )\right )^{m} \left (A +B \tan \left (f x +e \right )+C \tan \left (f x +e \right )^{2}\right )}{\left (c +d \tan \left (f x +e \right )\right )^{3}}d x\]

[In]

int((a+b*tan(f*x+e))^m*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x)

[Out]

int((a+b*tan(f*x+e))^m*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x)

Fricas [F]

\[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\int { \frac {{\left (C \tan \left (f x + e\right )^{2} + B \tan \left (f x + e\right ) + A\right )} {\left (b \tan \left (f x + e\right ) + a\right )}^{m}}{{\left (d \tan \left (f x + e\right ) + c\right )}^{3}} \,d x } \]

[In]

integrate((a+b*tan(f*x+e))^m*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x, algorithm="fricas")

[Out]

integral((C*tan(f*x + e)^2 + B*tan(f*x + e) + A)*(b*tan(f*x + e) + a)^m/(d^3*tan(f*x + e)^3 + 3*c*d^2*tan(f*x
+ e)^2 + 3*c^2*d*tan(f*x + e) + c^3), x)

Sympy [F]

\[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\int \frac {\left (a + b \tan {\left (e + f x \right )}\right )^{m} \left (A + B \tan {\left (e + f x \right )} + C \tan ^{2}{\left (e + f x \right )}\right )}{\left (c + d \tan {\left (e + f x \right )}\right )^{3}}\, dx \]

[In]

integrate((a+b*tan(f*x+e))**m*(A+B*tan(f*x+e)+C*tan(f*x+e)**2)/(c+d*tan(f*x+e))**3,x)

[Out]

Integral((a + b*tan(e + f*x))**m*(A + B*tan(e + f*x) + C*tan(e + f*x)**2)/(c + d*tan(e + f*x))**3, x)

Maxima [F(-1)]

Timed out. \[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\text {Timed out} \]

[In]

integrate((a+b*tan(f*x+e))^m*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x, algorithm="maxima")

[Out]

Timed out

Giac [F]

\[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\int { \frac {{\left (C \tan \left (f x + e\right )^{2} + B \tan \left (f x + e\right ) + A\right )} {\left (b \tan \left (f x + e\right ) + a\right )}^{m}}{{\left (d \tan \left (f x + e\right ) + c\right )}^{3}} \,d x } \]

[In]

integrate((a+b*tan(f*x+e))^m*(A+B*tan(f*x+e)+C*tan(f*x+e)^2)/(c+d*tan(f*x+e))^3,x, algorithm="giac")

[Out]

integrate((C*tan(f*x + e)^2 + B*tan(f*x + e) + A)*(b*tan(f*x + e) + a)^m/(d*tan(f*x + e) + c)^3, x)

Mupad [F(-1)]

Timed out. \[ \int \frac {(a+b \tan (e+f x))^m \left (A+B \tan (e+f x)+C \tan ^2(e+f x)\right )}{(c+d \tan (e+f x))^3} \, dx=\int \frac {{\left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )}^m\,\left (C\,{\mathrm {tan}\left (e+f\,x\right )}^2+B\,\mathrm {tan}\left (e+f\,x\right )+A\right )}{{\left (c+d\,\mathrm {tan}\left (e+f\,x\right )\right )}^3} \,d x \]

[In]

int(((a + b*tan(e + f*x))^m*(A + B*tan(e + f*x) + C*tan(e + f*x)^2))/(c + d*tan(e + f*x))^3,x)

[Out]

int(((a + b*tan(e + f*x))^m*(A + B*tan(e + f*x) + C*tan(e + f*x)^2))/(c + d*tan(e + f*x))^3, x)